package gene.android.accountingpro.equations;

import gene.android.accountingpro.finals.EquationNames;
import gene.android.accountingpro.finals.FieldList;

import java.util.ArrayList;
import java.util.List;

public class QuickRatio extends Equation{
	
	private double cash;
	private double short_term_investments;
	private double accounts_recievable;
	private double curent_liabilities;
	
	public QuickRatio(){}
	
	public QuickRatio(double cash, double short_term_investments, double accounts_receivable, double current_liabilities)
	{
		this.cash = cash;
		this.short_term_investments = short_term_investments;
		this.accounts_recievable = accounts_receivable;
		this.curent_liabilities = current_liabilities;
		value = ( (cash + short_term_investments + accounts_receivable ) / current_liabilities );
	}

	@Override
	public String getEquationName() {
		return EquationNames.QUICK_RATIO;
	}

	@Override
	public List<String> getRequiredFields() {
		List<String> requiredFields = new ArrayList<String>();
		requiredFields.add( FieldList.CASH );
		requiredFields.add( FieldList.SHORT_TERM_INVESTMENTS );
		requiredFields.add( FieldList.ACCOUNTS_RECIEVABLE );
		requiredFields.add( FieldList.CURRENT_LIABILITES );
		return requiredFields;
	}

	@Override
	public void setValues(double[] values) {
		cash = values[0];
		short_term_investments = values[1];
		accounts_recievable = values[2];
		curent_liabilities = values[3];
		solve();
	}

	@Override
	public String getSolvedEquationString() {
		return "( ( " + cash +" + " +short_term_investments +" + " + accounts_recievable +" ) / " + curent_liabilities +" ) = " + value;
	}

	@Override
	public void solve() {
		value = ( (cash + short_term_investments + accounts_recievable ) / curent_liabilities );
	}

	@Override
	public String getEquationString() {
		return "( ( " + FieldList.CASH +" + " +FieldList.SHORT_TERM_INVESTMENTS +" + " + FieldList.ACCOUNTS_RECIEVABLE +" ) / " + FieldList.CURRENT_LIABILITES +" )";
	}

}
